package com.wyj.mapper;

import com.wyj.pojo.LoginTicket;
import org.apache.ibatis.annotations.*;


@Mapper
public interface LoginTicketMapper {

    @Insert({
            "insert into login_ticket (user_id,ticket,status,expired)",
            "values(#{userId},#{ticket},#{status},#{expired})"
    })
    @Options(useGeneratedKeys = true,keyProperty = "id")//id是自增的
    int insertLoginTicket(LoginTicket loginTicket);

    @Select({"select * from login_ticket where ticket = #{ticket}"})
    LoginTicket selectLoginTicketById(String ticket);

    @Update({
            "<script>",
            "update login_ticket set status = #{status} where ticket = #{ticket}",
            "<if test = \"ticket != null\">",
            "</if>",
            "</script>"
    })
    int updateLoginTicket(String ticket,int status);



}
